package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**产品品牌实体类*/
@Entity
public class Productbrand {
    private int pbId;
    private String pbName;
    private Collection<Products> productsByPbId;
    private Productcategory productcategory;//多个品牌对应一个类型
    private List<Productcategory>  categoryList;//一个品牌也可以有多个类型

    @ManyToOne
    @JoinColumn(name = "pcId", referencedColumnName = "Pc_id")
    public Productcategory getProductcategory() {
        return productcategory;
    }
    public void setProductcategory(Productcategory productcategory) {
        this.productcategory = productcategory;
    }

    @OneToMany(mappedBy = "brank")
    public List<Productcategory> getCategoryList() {
        return categoryList;
    }

    public void setCategoryList(List<Productcategory> categoryList) {
        this.categoryList = categoryList;
    }
    @Id
    @Column(name = "Pb_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getPbId() {
        return pbId;
    }

    public void setPbId(int pbId) {
        this.pbId = pbId;
    }

    @Basic
    @Column(name = "Pb_name")
    public String getPbName() {
        return pbName;
    }

    public void setPbName(String pbName) {
        this.pbName = pbName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Productbrand that = (Productbrand) o;
        return pbId == that.pbId &&
                Objects.equals(pbName, that.pbName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pbId, pbName);
    }

    @OneToMany(mappedBy = "productbrandByPbId")
    public Collection<Products> getProductsByPbId() {
        return productsByPbId;
    }

    public void setProductsByPbId(Collection<Products> productsByPbId) {
        this.productsByPbId = productsByPbId;
    }
}
